/*
 *说明：孤儿账号审计
 *
 *@author liuxun 2012-03-06
*/

var opeForm;
var grid;

$(function(){
	opeForm = $('#opeForm');

	grid=$('#listTable').datagrid({
		frozenColumns:[[]],
		columns:[[

		    {title:'节点名称',field:'NODE_DECODE',align:'center',width:80},
		    
		    {title:'资源组',field:'RSC_GRP_NAME',align:'center',width:80},
		    
		    {title:'资源名称',field:'RSC_NAME',align:'center',width:80},
		    
		    {title:'资源账号',field:'RSC_ACC',align:'center',width:60},
		    
		    {title:'账号状态',field:'RSC_ACC_STATUS_DECODE',align:'center',width:80},
            
            {title:'账号类型',field:'RSC_ACC_TYPE_DECODE',align:'center',width:80},
		          
            {title:'接管时间',field:'CREATE_AT',align:'center',width:120},
            
            {title:'账号索引',field:'RSC_ACC_NO',align:'center',width:80},

            {title:'允许定期更新密码',field:'IS_UPDTE_PWD',align:'center',width:80,
            	formatter:function(value,rec){
            		return value ==  '1' ? '<font color="green"> √ </font>' : '<font color="red"> × </font>';
  			    }
            }
            
        ]]
	});

	queryOperation();

	$('#queryBtn').click(queryOperation);
	$('#clearBtn').click(clearOperation);
	$('#reloadBtn').click(refreshWin);
	$('#genReportBtn').click(genReporOperation);
});

//翻页时自动调用此函数
function onLoadPrev(msg){
	var queryParams=grid.datagrid('options').queryParams;
	queryParams['firstQuery']=false;
}

//查询操作
function queryOperation(){
	var params = opeForm.serializeObject();
	grid.datagrid("options").pageNumber = 1;
	grid.datagrid({
		url: 'AUDIT_REPORT!queryOrphanAccountList.do',
		queryParams: jQuery.extend({}, params, {'firstQuery': true})
	});
}

//清空操作（重置）
function clearOperation() {
	opeForm.resetForm();
}

//选择资源组
function select_c_rsc_grp() {
	var action = "C_RSC_GRP!showSelect.do";
	var row = showModalWin(action,'A2');
	
	if (row) {
		$('#rsc_grp_id').val(row.rsc_grp_id);
		$('#rsc_grp_name').val(row.rsc_grp_name);
	}
}

//选择资源
function select_c_rsc() {
	var action = "C_RSC!showSelect.do?model.rsc_grp_id="+$('#rsc_grp_id').val();
	var row = showModalWin(action,'A2');
	
	if (row) {
		$('#rsc_id').val(row.rsc_id);
		$('#rsc_name').val(row.rsc_name);
	}
}


// 生成孤儿账号审计报表
function genReporOperation() {
	opeForm.attr('action', 'AUDIT_REPORT!genOrphanAccountAuditReport.do');
	opeForm.attr('target', 'hideWindow');
	opeForm.submit();
}

// 操作成功后刷新列表
function afterOK(){
	queryOperation();
}